package commonLib;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.sprucetec.cabbage.commons.business.gis.GisGlobalConfig;
import com.sprucetec.cabbage.commons.business.gis.GisHttpsUtil;
import com.sprucetec.cabbage.commons.business.gis.dto.req.GetSaleAreaReq;
import com.sprucetec.cabbage.commons.business.gis.dto.resp.CityBeanResp;

import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @author cql
 */

public class GisTest {
    static GisGlobalConfig gisGlobalConfig = new GisGlobalConfig("pop-domain-app", "http://10.2.1.12:8207");

    public static void main(String[] args) {
        GisHttpsUtil.setGisGlobalConfig(gisGlobalConfig);
        //全部城市
        List<CityBeanResp> cityBeans = GisHttpsUtil.allCity();
        System.out.println(JSONObject.toJSON(cityBeans));
        //根据id查询城市
        Set<Integer> cityIds = new HashSet<>(2);
        Set<Integer> areaIds = new HashSet<>(2);
        Set<String> types = new HashSet<>(2);
        cityIds.add(1);
        cityIds.add(2);
        cityIds.add(3);

        areaIds.add(1);
        areaIds.add(2);
        areaIds.add(27);

        types.add("sitearea");
        types.add("salearea");
        types.add("warehouse");

        System.out.println(JSON.toJSON(GisHttpsUtil.getCityByIds(cityIds)));

        //getCityMap
        System.out.println(JSON.toJSON(GisHttpsUtil.getCityMap(cityIds)));
        Map<Integer, String> cityNameMap = GisHttpsUtil.getCityMapByIds(cityIds);
        System.out.println(JSON.toJSON(cityNameMap));

//坐标查询服务区
        System.out.println(JSON.toJSON(GisHttpsUtil.searchGisRegion("39.873364", "116.424987")));

//        (从下向上查询) 获取区域链
        GetSaleAreaReq saleAreaInfoBySiteParam = new GetSaleAreaReq();
        saleAreaInfoBySiteParam.setIds(areaIds);
        saleAreaInfoBySiteParam.setKey("servicearea");
        saleAreaInfoBySiteParam.setTypes(types);
        System.out.println(JSON.toJSON(GisHttpsUtil.getSaleAreaInfoBySiteAreaIds(saleAreaInfoBySiteParam)));

        System.out.println("售卖区");
        System.out.println(JSON.toJSON(GisHttpsUtil.getGisSimpleAreaByIds(areaIds)));
        System.out.println(JSON.toJSON(GisHttpsUtil.getSaleAreaByCityIds(cityIds)));
        System.out.println(JSON.toJSON(GisHttpsUtil.getProvinces()));
        System.out.println(JSON.toJSON(GisHttpsUtil.getCitysByProviceCode("0")));
        System.out.println(JSON.toJSON(GisHttpsUtil.getCitysByProviceCode("2")));

        System.out.println("揽收点");
        Set<Long> collectionStationIds = new HashSet<>();
        collectionStationIds.add(1L);
        collectionStationIds.add(2L);
        System.out.println(JSON.toJSON(GisHttpsUtil.getCollectionStationByIds(collectionStationIds)));
        System.out.println(JSON.toJSON(GisHttpsUtil.getCollectionStationByCityId(1)));
        System.out.println(JSON.toJSON(GisHttpsUtil.getCollectionStationByWarehouseId(1)));
        System.out.println("仓库");
        System.out.println(JSON.toJSON(GisHttpsUtil.warehouseList(1)));
        Set<Integer> warehouseIds = new HashSet<>(2);
        warehouseIds.add(0);
        warehouseIds.add(1);
        warehouseIds.add(1020202020);
        System.out.println(JSON.toJSON(GisHttpsUtil.getWarehouseByIds(warehouseIds)));

    }

}
